<?php
/**
 * Created by PhpStorm.
 * 招标订阅索引
 * User: liuxiu
 * Date: 2021/12/16
 * Time: 16:55
 */

namespace business\elasticsearch\models;


use business\elasticsearch\types\SubsBiddingMapConfigType;
use \yii\elasticsearch\ActiveRecord;

class SubsBiddingModel extends ActiveRecord
{
    public function attributes()
    {
        return [
            'uid', //主键id
            'title', //标题
            'intro', //简介
            'province_code', //省份code
            'province_name', //省份
            'source_type', //来源类型 1.开发商官网
            'release_time', //发布时间
            'stage', //公告类型 1.招标公告 2.中标公告
            'indexCreatedTime', //索引创建时间
        ];
    }

    public static function index()
    {
        return 'b2b_data_center.subsbidding';
    }

    public static function type()
    {
        return 'subsbidding';
    }


    public static function createIndex()
    {
        $db      = self::getDb();
        $command = $db->createCommand();
        $command->createIndex(self::index(), [
            'settings' => [
                'index' => [
                    'number_of_shards' => 5,
                    'number_of_replicas' => 1,
                    'analysis.analyzer.default.type' => 'ik_max_word',
                ]
            ],
            'mappings' => [self::type() => SubsBiddingMapConfigType::mapConfig()]]);
    }
}